<?php
/**
 * 
 * @author spring lee  新建出库单视图aiax验证数据功能方法，控制器不能继承admin，也不要加权限
 * @version 2014-6-7 上午9:09:45
 */
class  Controller_Deliverycheck extends Controller {
	
	/**
	 * Description
	 * 验证sku是否存在
	 */
	public function  action_checksku()
	{
		if(Deliverycheck::check_sku(trim($_POST['param']))){
			$jsonarr=array('status'=>'y','info'=>'验证通过！','sku'=>trim($_POST['param']));
		}else{
			$jsonarr=array('status'=>'n','info'=>'你输入的sku有误','sku'=>trim($_POST['param']));
		}
  	   	echo json_encode($jsonarr);
	}
	
	/**
	 * Description
	 * ajax根据sku调用控制器加载sku基础资料控制器
	 */
	public function  action_load_sku_info() {
		$sku = $_GET['sku'];
		$warehouseid = $_GET['warehouseid'];
		$result = Deliverycheck::load_sku_info($sku, $warehouseid);
		$jsonArr = array('status' => 'y','info' => $result);
		echo json_encode($jsonArr);
		exit;
	}
	
	
	
	
	public function  action_check_rate_name()
	{
		if(Rate::check_rate_name($_POST['param'])){
			$jsonarr=array('status'=>'y','info'=>'验证通过！');
		}else{
			$jsonarr=array('status'=>'n','info'=>'你输入的币种数据库没有记录');
		}
  	   	echo json_encode($jsonarr);
	}
	
	public function  action_check_saleaccount()
	{
		if(Rate::check_saleaccount($_POST['param'])){
			$jsonarr=array('status'=>'y','info'=>'验证通过！');
		}else{
			$jsonarr=array('status'=>'n','info'=>'你输入的销售帐号数据库没有记录');
		}
		echo json_encode($jsonarr);
	}
	
	public function  action_check_allsupp()
	{   $term=$_GET['term'];
	    $jsonarr= Basic::getallsupp($term);
		echo json_encode($jsonarr);
		exit();
	}
//验证出库单号是否存在，且是已临时借出的方式出库的
	public function  action_checkdoid()
	{  
		if($_POST['param']=='ok'){
			$jsonarr=array('status'=>'y','info'=>'验证通过！','deliveryorders_id'=>0);
		}else{

		$do = ORM::factory('deliveryorder')->where('id','=',trim($_POST['param']))->where('type','=',40)->find();
		if($do->id!=''){
			$jsonarr=array('status'=>'y','info'=>'验证通过！','deliveryorders_id'=>trim($_POST['param']));
		}else{
			$jsonarr=array('status'=>'n','info'=>'你输入的临时借出的出库单号错误','deliveryorders_id'=>trim($_POST['param']));
		}
		}
  	   	echo json_encode($jsonarr);
	}
}
